home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / shprst.arc / SHPRSET.ASM next >
Assembly Source File  |  1989-05-04  |  8KB  |  251 lines

  1. ;-----------------------------------------------------------------------
  2. ; SHPRSET.ASM
  3. ;
  4. ; (c) Copyright 1989, LAN Sharks, P.O. Box 825, Reisterstown, MD 21136
  5. ;
  6. ; Written by Brett Warthen
  7. ;
  8. ;-----------------------------------------------------------------------
  9. code segment
  10. assume cs:code,ds:code,es:code
  11.  
  12. ; Offsets in the PSP that contain the command line and length of command line
  13. org 80h
  14. param_length label byte
  15. org 81h
  16. parameter    label byte
  17.  
  18. ; .COM files start at 100h
  19. org 100h
  20.  
  21. start:
  22.           mov  ah,9                           ; Display LAN Sharks
  23.           mov  dx,offset ego_message          ;  copyright notice
  24.           int  21h
  25.  
  26.           xor  bh,bh                          ; Zero terminate parameter
  27.           mov  bl,param_length                ; string (make ASCIIZ)
  28.           mov  byte ptr parameter[bx],0
  29.  
  30.           xor  bx,bx
  31. get_parms:
  32.           cmp  bl,param_length                ; loop until end
  33.           jae  end_parms
  34.  
  35.           cmp  byte ptr parameter[bx],' '     ; white space?
  36.           jbe  next_please                    ; Yes...get next char
  37.  
  38.           cmp  byte ptr parameter[bx],'/'     ; command line delimiter?
  39.           jz   @F                             ; YES
  40.           cmp  byte ptr parameter[bx],'\'
  41.           jz   @F                             ; YES
  42.           cmp  byte ptr parameter[bx],'-'
  43.           jz   @F                             ; YES
  44.           jmp  end_parms                      ; No
  45.  
  46. @@:
  47.           inc  bx                             ; Get printer number
  48.           mov  al,byte ptr parameter[bx]
  49.           sub  al,'0'+1                       ; 0=LPT1, 1=LPT2, 2=LPT3
  50.           jb   next_please                    ; below LPT1
  51.           cmp  al,2
  52.           ja   next_please                    ; beyond LPT3
  53.           mov  default_printer,al             ; save it
  54.  
  55. next_please:
  56.           inc  bx                             ; read next char on
  57.           jmp  get_parms                      ;  command line
  58.  
  59. ; done with command line
  60. end_parms:
  61.           cmp  byte ptr parameter[bx],' '
  62.           ja   @F
  63.  
  64.           mov  dx,offset no_file_msg          ; No filename specified
  65.           jmp  error_exit
  66.  
  67. @@:
  68.           mov  ah,3Dh                         ; Open setup file
  69.           mov  al,40h                         ; Read only/Deny none
  70.           mov  dx,offset parameter
  71.           add  dx,bx
  72.           int  21h
  73.           jnc  @F                             ; file opened ok
  74.  
  75.           mov  ah,9                           ; file not opened ok
  76.           mov  dx,offset file_not_found_msg
  77.           int  21h
  78.  
  79.           xor  bh,bh
  80.           mov  bl,param_length
  81.           mov  byte ptr parameter[bx],'$'
  82.  
  83.           mov  ah,9
  84.           mov  dx,offset parameter
  85.           int  21h
  86.  
  87.           mov  ah,9
  88.           mov  dx,offset cr_lf_msg
  89.           int  21h
  90.  
  91.           jmp  error_exit                     ; get out
  92.  
  93. @@:
  94.           mov  bx,ax                          ; file opened ok -- read
  95.           mov  ah,3Fh
  96.           mov  cx,BUFFER_AREA_SIZE
  97.           mov  dx,offset buffer_area
  98.           int  21h
  99.  
  100.           jnc  @F
  101.           xor  ax,ax                          ; if error -- 0 bytes read
  102. @@:
  103.           cmp  ax,0                           ; zero bytes, don't check
  104.           jz   @F                             ;  for EOF
  105.  
  106.           mov  si,ax                          ; if editor put an EOF
  107.           dec  si                             ;  char (CTRL-Z) in the
  108.           cmp  byte ptr buffer_area[si],26    ;  file, then strip it...
  109.           jnz  @F
  110.           mov  byte ptr buffer_area[si],0
  111.           dec  ax
  112. @@:
  113.           mov  actual_buffer_size,ax
  114.  
  115.           mov  ah,3Eh                         ; close setup file
  116.           int  21h
  117.  
  118.           mov  ah,0B8h                        ; Get specific capture
  119.           mov  al,2                           ;  flags for printer
  120.           mov  cx,63                          ;  no. requested
  121.           mov  bx,offset reply_buffer
  122.           mov  dh,default_printer
  123.           int  21h
  124.  
  125.           cmp  al,0
  126.           jz   @F
  127.  
  128.           mov  dx,offset netware_error_msg    ; NetWare error
  129.           jmp  error_exit
  130.  
  131. @@:
  132.           cmp  lpt_capture_flag,0             ; Is a capture active
  133.           jnz  got_capture                    ;  on specified device?
  134.           cmp  file_capture_flag,0
  135.           jnz  got_capture
  136.  
  137.           mov  al,default_printer             ; No, display error
  138.           add  al,'0'+1
  139.           mov  not_capturing_no,al
  140.  
  141.           mov  dx,offset not_capturing_msg
  142.           jmp  error_exit
  143.  
  144. got_capture:
  145.           mov  ax,setup_buffer_hi             ; Get address of where
  146.           mov  es,ax                          ;  NetWare stores
  147.           mov  di,setup_buffer_lo             ;  setup_buffer
  148.           mov  ax,actual_buffer_size
  149.           cmp  word ptr es:[di],ax            ; First word is size
  150.           jae  @F                             ;  of buffer
  151.  
  152.           mov  dx,offset buffer_too_big_msg   ; We can't fit into
  153.           jmp  error_exit                     ;  default buffer size
  154.  
  155. @@:
  156.           inc  di
  157.           inc  di
  158.           mov  ax,actual_buffer_size          ; Next word contains
  159.           mov  word ptr es:[di],ax            ;  actual size of
  160.           inc  di                             ;  setup string
  161.           inc  di
  162.  
  163.           mov  cx,actual_buffer_size          ; copy our setup string
  164.           mov  si,offset buffer_area          ;  over
  165.           rep  movsb
  166.  
  167. exit:
  168.           mov  ax,4C00h                       ; Done
  169.           int  21h
  170.  
  171. error_exit:
  172.           push dx
  173.  
  174.           mov  ah,9                           ; Error -- display
  175.           mov  dx,offset usage_msg            ;  usage info
  176.           int  21h
  177.  
  178.           pop  dx                             ; ...and error msg
  179.           mov  ah,9
  180.           int  21h
  181.  
  182.           mov  ax,4CFFh                       ; SCRAM!
  183.           int  21h
  184.  
  185. ;-----------------------------------------------------------------------
  186. ; data area
  187. ;-----------------------------------------------------------------------
  188.  
  189. ego_message  db 'SHPRSET.COM -- (c) Copyright 1989 LAN Sharks',13,10
  190.              db '                                  P.O. Box 825',13,10
  191.              db '                                  Reisterstown, MD 21136',13,10,13,10,'$'
  192.  
  193. usage_msg    db 13,10
  194.              db 'Usage:  SHPRSET [/p] setup_file',13,10
  195.              db 'Where p is the printer number (1, 2 or 3)',13,10
  196.              db '      setup_file is the name of a file containing a printer setup string',13,10
  197.              db 13,10,'$'
  198.  
  199. default_printer    db 0
  200.  
  201. file_not_found_msg db 'File Not Found:  ',7,'$'
  202. cr_lf_msg          db 13,10,'$'
  203.  
  204. no_file_msg        db 'No setup file specified.',7,13,10,'$'
  205.  
  206. netware_error_msg  db 'UNKNOWN NetWare Error',7,13,10,'$'
  207.  
  208. not_capturing_msg  db 'LPT'
  209. not_capturing_no   db ?
  210.                    db ' is not being captured.',7,13,10,'$'
  211.  
  212. buffer_too_big_msg db 'PRINT HEADER Buffer Size is too large.',7,13,10
  213.                    db ' Increase value of PRINT HEADER= in SHELL.CFG or',13,10
  214.                    db ' decrease the size of the setup string',13,10,'$'
  215.  
  216. actual_buffer_size dw ?
  217. BUFFER_AREA_SIZE EQU 256
  218. buffer_area db BUFFER_AREA_SIZE dup (0)
  219.  
  220. reply_buffer label byte                       ; info returned from
  221.    status             db ?                    ;  set specific capture
  222.    print_flags        db ?                    ;  flags
  223.    tab_size           db ?
  224.    server_printer     db ?
  225.    num_of_copies      db ?
  226.    form_type          db ?
  227.                       db ?
  228.    banner_text        db 14 dup (?)
  229.    local_device       db ?
  230.    flush_timeout      dw ?
  231.    flush_on_close     db ?
  232.    max_lines          dw ?
  233.    max_chars          dw ?
  234.    form_name          db 13 dup (?)
  235.    lpt_capture_flag   db ?
  236.    file_capture_flag  db ?
  237.    timing_out_flag    db ?
  238.    setup_buffer_lo    dw ?
  239.    setup_buffer_hi    dw ?
  240.    reset_buffer_lo    dw ?
  241.    reset_buffer_hi    dw ?
  242.    server_queuing     db ?
  243.    in_progress        db ?
  244.    queue_flag         db ?
  245.    valid_flag         db ?
  246.    queue_id_no        dd ?
  247.    job_no             dw ?
  248.  
  249. code ends
  250. end start
  251.